//
//  OperationBillListHeadView.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2020/11/9.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "OperationBillListHeadView.h"

@interface OperationBillListHeadView ()

@property (nonatomic, strong) UIButton *allBtn;
@property (nonatomic, strong) UIButton *tiHuoBtn;
@property (nonatomic, strong) UIButton *jiaoHuoBtn;
@property (nonatomic, strong) UIButton *ganXianBtn;
@property (nonatomic, strong) UIButton *paiSongBtn;

@end

@implementation OperationBillListHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HexColor(0xffffff);
        
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 1)];
        line.backgroundColor = Color_backgroundColor;
        [self addSubview:line];
        
        CGFloat btnW = 52;
        CGFloat btnH = 28;
        CGFloat margin = (ScreenW - 5 * btnW) * 0.166666;
        
        self.allBtn = [[UIButton alloc] initWithFrame:CGRectMake(margin, 6, btnW, btnH)];
        [self.allBtn setTitle:@"全部" forState:0];
        [self.allBtn setTitleColor:Color_ThemeColor forState:0];
        self.allBtn.titleLabel.font = BoldFontOfSize(14);
        self.allBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
        self.allBtn.layer.masksToBounds = YES;
        self.allBtn.layer.cornerRadius = btnH * 0.5;
        [self.allBtn addTarget:self action:@selector(allClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.allBtn];
        
        self.tiHuoBtn = [[UIButton alloc] initWithFrame:CGRectMake(margin + self.allBtn.nim_right, 6, btnW, btnH)];
        [self.tiHuoBtn setTitle:@"提货" forState:0];
        [self.tiHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
        self.tiHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.tiHuoBtn addTarget:self action:@selector(tiHuoClick) forControlEvents:UIControlEventTouchUpInside];
        self.tiHuoBtn.layer.masksToBounds = YES;
        self.tiHuoBtn.layer.cornerRadius = btnH * 0.5;
        [self addSubview:self.tiHuoBtn];
        
        self.jiaoHuoBtn = [[UIButton alloc] initWithFrame:CGRectMake(margin + self.tiHuoBtn.nim_right, 6, btnW, btnH)];
        [self.jiaoHuoBtn setTitle:@"交货" forState:0];
        [self.jiaoHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
        self.jiaoHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.jiaoHuoBtn addTarget:self action:@selector(jiaoHuoClick) forControlEvents:UIControlEventTouchUpInside];
        self.jiaoHuoBtn.layer.masksToBounds = YES;
        self.jiaoHuoBtn.layer.cornerRadius = btnH * 0.5;
        [self addSubview:self.jiaoHuoBtn];
        
        self.ganXianBtn = [[UIButton alloc] initWithFrame:CGRectMake(margin + self.jiaoHuoBtn.nim_right, 6, btnW, btnH)];
        [self.ganXianBtn setTitle:@"干线" forState:0];
        [self.ganXianBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
        self.ganXianBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.ganXianBtn addTarget:self action:@selector(ganXianClick) forControlEvents:UIControlEventTouchUpInside];
        self.ganXianBtn.layer.masksToBounds = YES;
        self.ganXianBtn.layer.cornerRadius = btnH * 0.5;
        [self addSubview:self.ganXianBtn];
        
        self.paiSongBtn = [[UIButton alloc] initWithFrame:CGRectMake(margin + self.ganXianBtn.nim_right, 6, btnW, btnH)];
        [self.paiSongBtn setTitle:@"派送" forState:0];
        [self.paiSongBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
        self.paiSongBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.paiSongBtn addTarget:self action:@selector(paiSongClick) forControlEvents:UIControlEventTouchUpInside];
        self.paiSongBtn.layer.masksToBounds = YES;
        self.paiSongBtn.layer.cornerRadius = btnH * 0.5;
        [self addSubview:self.paiSongBtn];
        
    }
    return self;
}

- (void)allClick {
    if (self.clickBlock) {
        self.clickBlock(0);
    }
    [self.allBtn setTitleColor:Color_ThemeColor forState:0];
    self.allBtn.titleLabel.font = BoldFontOfSize(14);
    self.allBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
    
    [self.tiHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.tiHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.tiHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.jiaoHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.jiaoHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.jiaoHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.ganXianBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.ganXianBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.ganXianBtn.backgroundColor = HexColor(0xffffff);
    
    [self.paiSongBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.paiSongBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.paiSongBtn.backgroundColor = HexColor(0xffffff);
}

- (void)tiHuoClick {
    if (self.clickBlock) {
        self.clickBlock(1);
    }
    
    [self.tiHuoBtn setTitleColor:Color_ThemeColor forState:0];
    self.tiHuoBtn.titleLabel.font = BoldFontOfSize(14);
    self.tiHuoBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
    
    [self.allBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.allBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.allBtn.backgroundColor = HexColor(0xffffff);
    
    [self.jiaoHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.jiaoHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.jiaoHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.ganXianBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.ganXianBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.ganXianBtn.backgroundColor = HexColor(0xffffff);
    
    [self.paiSongBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.paiSongBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.paiSongBtn.backgroundColor = HexColor(0xffffff);
}

- (void)jiaoHuoClick {
    if (self.clickBlock) {
        self.clickBlock(4);
    }
    
    [self.jiaoHuoBtn setTitleColor:Color_ThemeColor forState:0];
    self.jiaoHuoBtn.titleLabel.font = BoldFontOfSize(14);
    self.jiaoHuoBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
    
    [self.tiHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.tiHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.tiHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.allBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.allBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.allBtn.backgroundColor = HexColor(0xffffff);
    
    [self.ganXianBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.ganXianBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.ganXianBtn.backgroundColor = HexColor(0xffffff);
    
    [self.paiSongBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.paiSongBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.paiSongBtn.backgroundColor = HexColor(0xffffff);
}

- (void)ganXianClick {
    if (self.clickBlock) {
        self.clickBlock(2);
    }
    [self.ganXianBtn setTitleColor:Color_ThemeColor forState:0];
    self.ganXianBtn.titleLabel.font = BoldFontOfSize(14);
    self.ganXianBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
    
    [self.tiHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.tiHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.tiHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.jiaoHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.jiaoHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.jiaoHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.allBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.allBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.allBtn.backgroundColor = HexColor(0xffffff);
    
    [self.paiSongBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.paiSongBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.paiSongBtn.backgroundColor = HexColor(0xffffff);
}

- (void)paiSongClick {
    if (self.clickBlock) {
        self.clickBlock(3);
    }
    
    [self.paiSongBtn setTitleColor:Color_ThemeColor forState:0];
    self.paiSongBtn.titleLabel.font = BoldFontOfSize(14);
    self.paiSongBtn.backgroundColor = HexColorA(0x3D68EB, 0.1);
    
    [self.tiHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.tiHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.tiHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.jiaoHuoBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.jiaoHuoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.jiaoHuoBtn.backgroundColor = HexColor(0xffffff);
    
    [self.ganXianBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.ganXianBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.ganXianBtn.backgroundColor = HexColor(0xffffff);
    
    [self.allBtn setTitleColor:HexColor(0x9C9DB3) forState:0];
    self.allBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    self.allBtn.backgroundColor = HexColor(0xffffff);
}

@end
